﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace diploma.test.core
{
    public class PropertyRow
    {
        public PropertyRow(IEnumerable<PropertyItem> _vals, List<string> properties)
        {
            this._values = new List<PropertyItem>(properties.Count);
            this._values.AddRange(_vals);
            this.cellCount = this._values.Count;
        }

        public PropertyRow(int cellCount, List<string> properties)
        {
            this.cellCount = cellCount;
            this._values = new List<PropertyItem>(cellCount);
            for (int i = 0; i < cellCount; i++)
            {
                this._values.Add(new PropertyItem(properties[i], ""));
            }
        }

        private int cellCount = 0;
        private List<PropertyItem> _values = null;
        public PropertyItem[] RowValues
        {
            get
            {
                return this._values.ToArray();
            }
        }

        public void modifyCell(int index, string value)
        {
            if (_values != null && cellCount > 0)
            {
                if (index >= 0 && index < cellCount)
                {
                    _values[index].Value = value;
                }
            }
        }

        public void modifyRow(List<string> values)
        {
            for (int i = 0; i < cellCount; i++)
            {
                this._values[i].Value = values[i];
            }
        }
    }
}
